package org.budo.spring.beans.factory.xml.parser.async;

import org.budo.spring.beans.factory.xml.parser.BudoSpringBeanDefinitionParser;
import org.budo.support.spring.bean.factory.support.BeanBuilder;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

import lombok.extern.slf4j.Slf4j;

/**
 * @author lmw
 * 
 * @see com.alibaba.druid.support.spring.stat.config.DruidStatBeanDefinitionParser
 */
@Slf4j
public class AsyncReferenceBeanDefinitionParser extends BudoSpringBeanDefinitionParser {
    private static final String BUDO_ASYNC_REFERENCE_BEAN_TYPE = "org.budo.dubbo.protocol.async.config.BudoAsyncReferenceBean";

    @Override
    public BeanDefinition parse(Element element, ParserContext parserContext) {
        String id = "budo:async-ref:" + element.getAttribute("interface");

        new BeanBuilder() //
                .id(id) //
                .type(BUDO_ASYNC_REFERENCE_BEAN_TYPE) //
                .registerTo(parserContext.getRegistry()); //

        log.info("#25 beanName=" + id);
        return null;
    }
}